﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Domain;

namespace DomainTests
{
    [TestClass]
    public class Computations
    {
        [TestMethod]
        public void EqualVerticesGiveZeroSquare()
        {
            var point = new Point(1.0, -1.0);
            var triangle = new Triangle(point, point, point);
           
            var square = triangle.Square;

            Assert.AreEqual(0.0, square, Constants.Epsilon);
        }
        [TestMethod]
        public void CollinearVerticesGiveZeroSquare()
        {
            var pointA = new Point(0.0, -1.0);
            var pointB = new Point(0.0,  0.0);
            var pointC = new Point(0.0,  1.0);
            var triangle = new Triangle(pointA, pointB, pointC);

            var square = triangle.Square;

            Assert.AreEqual(0.0, square, Constants.Epsilon);
        }
        [TestMethod]
        public void SquareOfNotDegenerateTriangleMustBeNonzero()
        {
            var pointA = new Point(0.0, 0.0);
            var pointB = new Point(1.0, 0.0);
            var pointC = new Point(0.0, 1.0);
            var triangle = new Triangle(pointA, pointB, pointC);

            var square = triangle.Square;

            Assert.AreEqual(0.5, square, Constants.Epsilon);
        }
        [TestMethod]
        public void PerimeterOfNotDegenerateTriangleMustBeNonzero()
        {
            var pointA = new Point(0.0, 0.0);
            var pointB = new Point(3.0, 0.0);
            var pointC = new Point(0.0, 4.0);
            var triangle = new Triangle(pointA, pointB, pointC);

            var perimeter = triangle.Perimeter;

            Assert.AreEqual(12.0, perimeter, Constants.Epsilon);
        }
        [TestMethod]
        public void PerimeterOfDegeneratedTriangleGivesSegmentLength()
        {
            var pointA = new Point(0.0, 0.0);
            var pointB = new Point(0.0, 1.0);
            var pointC = new Point(0.0, 2.0);
            var triangle = new Triangle(pointA, pointB, pointC);

            var perimeter = triangle.Perimeter;

            Assert.AreEqual(2.0, perimeter, Constants.Epsilon);
        }
    }
}
